<?php

/**
 *  @FileComment            [权限管理模型]
 *  @ProjectName             项目名称：JDshop
 *  @FileName                   文件名称：AccessModel.class.php
 *  @Author                       yuerengui <596580041@qq.com>
 *  @Date                          2014-10-26 16:47:40
 *  *
 */
class AccessModel extends Model {

        public $table = 'access';
        public $validate = array(
            array('rid', '_isset', '该权限已经添加，请不要重复添加！', 2, 3)
        );

        public function _isset($name, $value, $msg, $arg) {
                $data = $this->where(array('rid' => $value, 'nid' => Q('post.nid', 0, 'intval')))->find();
                if (!empty($data)) {
                        return $msg;
                } else {
                        return true;
                }
        }

        public function del_data($rid, $nid) {
                return $this->where(array('rid' => $rid, 'nid' => $nid))->del();
        }

        public function add_data() {
                return $this->add();
        }

}
